C_FILE := $(wildcard *.c)
C_UDP_FILE := $(wildcard ../udp/*.c)
C_IP_FILE := $(wildcard ../ip/*.c)
C_ARP_FILE := $(wildcard ../arp/*.c)
C_UTIL_FILE := $(wildcard ../common/*.c)
O_ONEWAY_FILE := $(patsubst %.c,%.o,$(filter %oneway.c,$(C_FILE)))
O_bothway_FILE := $(patsubst %.c,%.o,$(filter %bothway.c,$(C_FILE)))
O_UDP_FILE := $(patsubst %.c,%.o,$(filter ../udp/udp%.c,$(C_UDP_FILE)))
O_IP_FILE := $(patsubst %.c,%.o,$(filter ../ip/ip%.c,$(C_IP_FILE)))
O_ARP_FILE := $(patsubst %.c,%.o,$(filter ../arp/arp%.c,$(C_ARP_FILE)))
O_UTIL_FILE := $(patsubst %.c,%.o,$(filter ../common/util%.c,$(C_UTIL_FILE)))
O_C_FILE := $(patsubst %.c,%.o,$(C_FILE))

all: oneway.out bothway.out


oneway.out: $(O_UTIL_FILE) $(O_ONEWAY_FILE)
	gcc $^ -o $@

bothway.out: $(O_UTIL_FILE) $(O_bothway_FILE)
	gcc $^ -o $@

%.o: %.c
	gcc -c $^ -o $@

clean: 
	rm *.o -f
	rm *.out -f